package cn.bone.gateway01.conf;

import cn.bone.gateway01.filter.AuthFilter;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Config {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder){
        RouteLocator routeLocator = builder.routes()
                .route(r -> {
                    return r.path("/baidu/**").uri("https://baidu.com");
                })
                .route(r -> {
                    return r.path("/163").uri("https://163.com");
                })
                .route(r -> {
                    return r.header("api","123").uri("https://www.sohu.com");
                })
                .build();
        return routeLocator;
    }

    @Bean
    public AuthFilter authFilter(){
        return new AuthFilter();
    }
}
